package basics.day18.ArrayList.CollectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * Collection不添加任何类型，集合可以存任意类型的对象
 */
public class IteratorTrans {
    public static void main(String[] args) {
        fun_1();
    }

    public static void fun_1() {
        Collection c = new ArrayList();
        c.add("张喜");
        c.add("111");
        Iterator i = c.iterator();
        while (i.hasNext()) {
            // System.out.println(i.next());
            /**
             * Collection存储的任意类型，其实就是Object，我们存储的String实际拆箱为Object
             */
            String s = (String) i.next();
            System.out.println(s.length());
        }
    }
}
